<template>
  <div>
    <el-table :data="Wageslist" style="" :header-cell-style="{ background: '#f0f0f0', height: '48px' }">
      <el-table-column prop="id" label="序号" width="55px" />
      <el-table-column prop="username" label="姓名" />
      <el-table-column prop="mobile" label="手机号" />
      <el-table-column prop="workNumber" label="工号" />
      <el-table-column prop="formOfEmployment" label="聘用方式">
        <template #default="scope">
          <span v-if="scope.row.formOfEmployment == 1">正式</span>
          <span v-else-if="scope.row.formOfEmployment == 2">非正式</span>
        </template>
      </el-table-column>
      <el-table-column prop="departmentName" label="部门" />
      <el-table-column prop="timeOfEntry" label="入职时间" />
      <el-table-column prop="currentBasicSalary" label="工资基数" />
      <el-table-column prop="subsidyName" label="津贴方案" />
      <el-table-column prop="positionName" label="操作">
        <template #default="scope">
          <el-button @click="handleding(scope.$index, scope.row)"
            style="background-color: #f56c6c;color:#fff;border-radius: 0px;border:none;"
            v-if="scope.row.currentBasicSalary == 0">定薪</el-button>
          <el-button @click="handletiao(scope.$index, scope.row)"
            style="background-color: #2752fb;color:#fff;border-radius: 0px;border:none;" v-else>调薪</el-button>
          <el-button @click="handledit(scope.$index, scope.row)" plain>查看</el-button>
        </template>
      </el-table-column>
    </el-table>
    <alerts :userId="userId" :userdata="userdata" />
  </div>
</template>

<script setup lang="ts">
import { ref } from 'vue'
import { useStore } from '@/stores/counter'
import { getUserWages } from '@/api/Wages'
import { useRouter } from 'vue-router'
const router = useRouter()
const store = useStore();
defineProps(["Wageslist"]);
let userId = ref('')
let userdata = ref('')
const handleding = (index: number, row: any) => {
  store.$state.dialogVisible = true
  store.$state.alerttitle = '定薪'
  userId.value = row.id
}
const handletiao = (index: number, row: any) => {
  store.$state.dialogVisible = true
  store.$state.alerttitle = '调薪'
  getUserWages(row.id).then(res => {
    userdata.value = res.data.data
  })
}
const handledit = (index: number, row: any) => {
  router.push(`/home/salary/detail?id=${row.id}/yearMonth=202312`)
}
</script>

<style scoped></style>
